#version 460

#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
//#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require
#include "../../../../core/shader_std.h"


layout(location=0) out vec4 outColor;
layout(location=1) out vec4 outColorB;
//layout(depth_greater) out float gl_FragDepth;

layout(location = 0) in vec4 vColor;
layout(location = 1) in vec2 vUV;
layout(location = 2) in flat float gap;
layout(location = 3) in flat float offset;
layout(location = 4) in flat uint shaderType;
layout(location = 5) in float shaderBlur;
layout(location = 6) in float shaderShadow;



void main(void){
	
	switch(shaderType & 63){
		case DEF_2DShaderType_Stripe: {
			//uint k = uint( (vUV.y + offset) / gap);
			float a = fract((floor((vUV.y - offset) / gap)) / 2) * 2;
			
			outColor = mix(vColor, vColor * 0.9, a);
			break;
		}
		case DEF_2DShaderType_Checkerboard: {
			vec2 uv = floor(gl_FragCoord.xy / gap);
			outColor = mod(uv.x + uv.y, 2.0) * vec4(vColor);
			break;
		}
		
		default :{
			outColor = vColor;
		}
	}

	switch(shaderType & 192){
		case 128:{
			outColorB.b = 0.91;
			break;
		}
		default:{
			outColorB.b = 0;
			break;
		}
	}
	
	outColorB.r = shaderBlur;
	outColorB.g = shaderShadow;
	//outColorB.b = uintBitsToFloat(shaderType & 192);
	//outColorB.b = 0.5;
	outColorB.a = outColor.a;
}



 